﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.IO;

namespace TeamWork_Client
{
    public partial class Register : Form
    {
        public Register()
        {
            InitializeComponent();
        }

        public UserDetails User = null;

        private void commandLink1_Click(object sender, EventArgs e)
        {
            Dictionary<string, string> headers = new Dictionary<string,string>();
            headers.Add("TYPE", "NewUser");
            headers.Add("uCred", textBox3.Text + "|" + textBox1.Text + "|" + comboBox1.Text);
            HttpWebResponse res = HTTPManager.SendMessage2(Form1.server + ":55987", "", headers);
            BinaryReader reader = new BinaryReader(res.GetResponseStream());
            UserDetails udetails = new UserDetails();
            udetails.Username = reader.ReadString();
            udetails.Password = reader.ReadString();
            udetails.Role = reader.ReadString();
            udetails.ID = reader.ReadInt32();
            reader.Close();

            User = udetails;
            MessageBox.Show("User has been registered and locked in the server.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
    }
}
